package com.ljz.utils;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

@Component
public class PageUtil {
    public static Map<String,Object> getreqMap(int currentPage,int pageSize){
        currentPage = (currentPage-1)*pageSize;
        Map<String,Object> map = new HashMap<>();
        map.put("currentPage", currentPage);
        map.put("pageSize", pageSize);
        return map;
    }

    public static Map<String,Object> getrespMap(int currentPage,int pageSize,int num){
        int total= 0;
        if(num%pageSize==0){
            total= num/pageSize;
        }else {
            total= num/pageSize+1;
        }
        Map<String,Object>map = new HashMap<>();
        map.put("currentPage", currentPage);
        map.put("pageSize", pageSize);
        map.put("pageNum", total);
        return map;
    }
}
